package com.itheima.sh;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;
import static com.itheima.sh.utils.Util.getRequestAttributes;

/**
 * @author win10
 */
@Configuration
@Aspect
public class BeforeLog {
    private static final Logger log = LoggerFactory.getLogger(BeforeLog.class);
    @Before(value = "within(com.itheima.sh.*)")
    public void before(JoinPoint joinPoint){
        String ipStr = getRequestAttributes().getRequest().getRemoteAddr();
        log.info("RequesterIp:" + ipStr);
    }
}
